<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>slot自定义 | d2-crud-plus</title>
    <meta name="generator" content="VuePress 1.5.2">
    <link rel="icon" href="/d2-crud-plus/icon-only.png">
    <link rel="manifest" href="/d2-crud-plus/manifest.json">
    <link rel="apple-touch-icon" href="/d2-crud-plus/icons/apple-touch-icon-152x152.png">
    <link rel="mask-icon" href="/d2-crud-plus/icons/safari-pinned-tab.svg" color="#3eaf7c">
    <meta name="description" content="d2-crud-plus doc">
    <meta name="theme-color" content="#3eaf7c">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="msapplication-TileImage" content="/icons/msapplication-icon-144x144.png">
    <meta name="msapplication-TileColor" content="#000000">
    <link rel="preload" href="/d2-crud-plus/assets/css/0.styles.094573b2.css" as="style"><link rel="preload" href="/d2-crud-plus/assets/js/app.9c9ff646.js" as="script"><link rel="preload" href="/d2-crud-plus/assets/js/2.9f3ba775.js" as="script"><link rel="preload" href="/d2-crud-plus/assets/js/66.b3a44945.js" as="script"><link rel="prefetch" href="/d2-crud-plus/assets/js/10.768312da.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/11.88f0302a.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/12.0a517745.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/13.a305030c.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/14.d7129909.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/15.155c94d2.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/16.26c6c56e.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/17.e99a2516.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/18.4070aced.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/19.2973f5fd.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/20.98a470da.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/21.4a9a425c.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/22.e3df0266.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/23.c3b1f111.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/24.06580ff4.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/25.90694896.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/26.aa14de9a.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/27.fae09a5a.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/28.5e7a8b41.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/29.01177fca.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/3.b899e7a1.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/30.50b37a03.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/31.12c9c609.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/32.003f7e14.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/33.32ac431f.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/34.2ba18ffa.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/35.cf663eb5.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/36.2cb165db.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/37.5f369dc4.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/38.c40206e6.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/39.b4045a79.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/4.6d40d8fb.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/40.819f2369.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/41.443d0cf0.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/42.7a8402af.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/43.9d74c7d1.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/44.9bac8686.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/45.ffdb2000.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/46.01feec93.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/47.fd9aabfc.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/48.6c73355e.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/49.f6fd43e8.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/5.8571b144.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/50.c5de948a.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/51.002c2494.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/52.a6e0e1fe.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/53.5555efff.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/54.434a586a.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/55.3d1d5e49.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/56.8396c799.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/57.346fc7e0.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/58.6cb05cfb.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/59.066b3e6d.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/6.8660d829.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/60.090af84b.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/61.be1e3ade.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/62.8e56567e.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/63.1ba8b586.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/64.53572d02.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/65.8d5fd2db.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/67.70d9fe09.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/68.9bd08d8c.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/69.e18290df.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/7.d8550247.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/70.a8143954.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/71.aa8ba6ae.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/8.b8c6f50a.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/9.bb5c3b5b.js">
    <link rel="stylesheet" href="/d2-crud-plus/assets/css/0.styles.094573b2.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/d2-crud-plus/" class="home-link router-link-active"><!----> <span class="site-name">d2-crud-plus</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/d2-crud-plus/guide/" class="nav-link router-link-active">
  指南
</a></div><div class="nav-item"><a href="http://qiniu.veryreader.com/D2CrudPlusExample/index.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  演示
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <a href="https://github.com/greper/d2-crud-plus" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/d2-crud-plus/guide/" class="nav-link router-link-active">
  指南
</a></div><div class="nav-item"><a href="http://qiniu.veryreader.com/D2CrudPlusExample/index.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  演示
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <a href="https://github.com/greper/d2-crud-plus" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>指南</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/" class="sidebar-link">介绍</a></li><li><a href="/d2-crud-plus/guide/quickstart.html" class="sidebar-link">快速上手</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>进阶</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/mixins.html" class="sidebar-link">d2CrudPlus.crud</a></li><li><a href="/d2-crud-plus/guide/options.html" class="sidebar-link">crud配置项</a></li><li><a href="/d2-crud-plus/guide/structure.html" class="sidebar-link">数据结构</a></li><li><a href="/d2-crud-plus/guide/component.html" class="sidebar-link">组件配置</a></li><li><a href="/d2-crud-plus/guide/column-type.html" class="sidebar-link">字段类型</a></li><li><a href="/d2-crud-plus/guide/types.html" class="sidebar-link">字段类型列表</a></li><li><a href="/d2-crud-plus/guide/slot.html" class="active sidebar-link">slot自定义</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/slot.html#什么时候你需要slot自定义" class="sidebar-link">什么时候你需要slot自定义</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/slot.html#form表单slot自定义" class="sidebar-link">form表单slot自定义</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/slot.html#行展示组件slot自定义" class="sidebar-link">行展示组件slot自定义</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/slot.html#search表单组件slot自定义" class="sidebar-link">search表单组件slot自定义</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/slot.html#表单helper的slot自定义" class="sidebar-link">表单helper的slot自定义</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/slot.html#slot快捷字段类型" class="sidebar-link">slot快捷字段类型</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/slot.html#演示示例" class="sidebar-link">演示示例</a></li></ul></li><li><a href="/d2-crud-plus/guide/extends.html" class="sidebar-link">自定义扩展</a></li><li><a href="/d2-crud-plus/guide/dict.html" class="sidebar-link">数据字典</a></li><li><a href="/d2-crud-plus/guide/event.html" class="sidebar-link">事件监听</a></li><li><a href="/d2-crud-plus/guide/flat-data.html" class="sidebar-link">数据扁平化</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>附加功能</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/permission.html" class="sidebar-link">权限管理</a></li><li><a href="/d2-crud-plus/guide/generate.html" class="sidebar-link">代码生成</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>更多帮助</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/upgrade.html" class="sidebar-link">版本升级</a></li><li><a href="/d2-crud-plus/guide/breakingchange.html" class="sidebar-link">版本变更说明</a></li><li><a href="/d2-crud-plus/guide/questions.html" class="sidebar-link">常见问题</a></li><li><a href="/d2-crud-plus/guide/contact.html" class="sidebar-link">联系作者</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>extends文档</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/extends/area-selector.html" class="sidebar-link">省市区选择组件</a></li><li><a href="/d2-crud-plus/guide/extends/avatar-cropper.html" class="sidebar-link">头像裁剪上传</a></li><li><a href="/d2-crud-plus/guide/extends/file-uploader.html" class="sidebar-link">文件上传组件</a></li><li><a href="/d2-crud-plus/guide/extends/full-editor.html" class="sidebar-link">富文本</a></li><li><a href="/d2-crud-plus/guide/extends/icon-selector.html" class="sidebar-link">icon选择组件</a></li><li><a href="/d2-crud-plus/guide/extends/tree-selector.html" class="sidebar-link">树形选择组件</a></li><li><a href="/d2-crud-plus/guide/extends/uploader.html" class="sidebar-link">文件上传lib</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>组件文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>ChangeLog</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="slot自定义"><a href="#slot自定义" class="header-anchor">#</a> slot自定义</h1> <h2 id="什么时候你需要slot自定义"><a href="#什么时候你需要slot自定义" class="header-anchor">#</a> 什么时候你需要slot自定义</h2> <ul><li>需求比较复杂，现有的字段类型和组件无法满足你的需求</li> <li>需求并不通用，没必要写一个自定义扩展</li> <li>想要将行列展示美化一下</li> <li>想要使用filter</li> <li>合并多个字段到一个格子里面</li></ul> <h2 id="form表单slot自定义"><a href="#form表单slot自定义" class="header-anchor">#</a> form表单slot自定义</h2> <p>当现有的表单组件均无法满足你的需求时，你可以自己写form表单</p> <p>1.配置<code>form.slot=true</code></p> <div class="language-js extra-class"><div class="highlight-lines"><br><br><br><br><br><div class="highlighted"> </div><br><br><br><br></div><pre class="language-js"><code><span class="token keyword">let</span> crudOption<span class="token operator">=</span><span class="token punctuation">{</span>
  columns<span class="token punctuation">:</span><span class="token punctuation">[</span> 
    <span class="token punctuation">{</span> 
      title <span class="token punctuation">:</span> <span class="token string">'主题列表'</span><span class="token punctuation">,</span>
      key <span class="token punctuation">:</span> <span class="token string">'topics'</span><span class="token punctuation">,</span>
      form<span class="token punctuation">:</span> <span class="token punctuation">{</span> slot <span class="token punctuation">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</code></pre></div><ol start="2"><li>d2-crud 下写你的slot template，slot名称为 <code>column.key+'FormSlot'</code></li></ol> <div class="language-html extra-class"><div class="highlight-lines"><br><br><div class="highlighted"> </div><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></div><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>template</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>d2-crud-x</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>template</span> <span class="token attr-name">slot</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>topicsFormSlot<span class="token punctuation">&quot;</span></span> <span class="token attr-name">slot-scope</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>scope<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>el-input</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>d2-mb-5<span class="token punctuation">&quot;</span></span> <span class="token attr-name">v-for</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>(item,index) in scope.form.topics<span class="token punctuation">&quot;</span></span> <span class="token attr-name">:key</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>index<span class="token punctuation">&quot;</span></span>   <span class="token attr-name">v-model</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>scope.form.topics[index]<span class="token punctuation">&quot;</span></span> <span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>el-button</span> <span class="token attr-name">slot</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>append<span class="token punctuation">&quot;</span></span> <span class="token attr-name">icon</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>el-icon-remove-outline<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">v-on:</span>click</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>removeTopic(index)<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>el-button</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>el-input</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>el-button</span> <span class="token attr-name"><span class="token namespace">v-on:</span>click</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>addTopic<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>添加主题<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>el-button</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>template</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>d2-crud-x</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>template</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span><span class="token script"><span class="token language-javascript">
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
  methods<span class="token punctuation">:</span> <span class="token punctuation">{</span>
   <span class="token function">addTopic</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
     <span class="token keyword">let</span> form <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getEditForm</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 通过此方法可以获得formData</span>
     <span class="token keyword">if</span> <span class="token punctuation">(</span>form<span class="token punctuation">.</span>topics <span class="token operator">==</span> <span class="token keyword">null</span> <span class="token operator">||</span> form<span class="token punctuation">.</span>topics <span class="token operator">===</span> <span class="token string">''</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
       form<span class="token punctuation">.</span>topics <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span>
     <span class="token punctuation">}</span>
     form<span class="token punctuation">.</span>topics<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">)</span>
   <span class="token punctuation">}</span><span class="token punctuation">,</span>
   <span class="token function">removeTopic</span> <span class="token punctuation">(</span><span class="token parameter">index</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
     <span class="token keyword">let</span> form <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getEditForm</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 通过此方法可以获得formData</span>
     form<span class="token punctuation">.</span>topics<span class="token punctuation">.</span><span class="token function">splice</span><span class="token punctuation">(</span>index<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span>
   <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>

</code></pre></div><h2 id="行展示组件slot自定义"><a href="#行展示组件slot自定义" class="header-anchor">#</a> 行展示组件slot自定义</h2> <p>当行的默认展示不符合你的需求时，或者你想写filter，你可以使用行展示组件slot<br>
例如你想合并添加时间和修改时间到一个格子里去<br>
1.配置<code>rowSlot=true</code></p> <div class="language-js extra-class"><div class="highlight-lines"><br><br><br><br><br><br><div class="highlighted"> </div><br><br><br><br></div><pre class="language-js"><code><span class="token keyword">let</span> crudOption<span class="token operator">=</span><span class="token punctuation">{</span>
  columns<span class="token punctuation">:</span><span class="token punctuation">[</span> 
    <span class="token punctuation">{</span> 
      title <span class="token punctuation">:</span> <span class="token string">'时间'</span><span class="token punctuation">,</span>
      key <span class="token punctuation">:</span> <span class="token string">'createData'</span><span class="token punctuation">,</span>
      type <span class="token punctuation">:</span> <span class="token string">'date'</span><span class="token punctuation">,</span>
      rowSlot<span class="token punctuation">:</span> <span class="token boolean">true</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</code></pre></div><ol start="2"><li>d2-crud 下写你的slot template ,slot名称为 <code>column.key+'Slot'</code></li></ol> <div class="language-html extra-class"><div class="highlight-lines"><br><div class="highlighted"> </div><br><br><br><br><br></div><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>d2-crud-x</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>template</span> <span class="token attr-name">slot</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>createDateSlot<span class="token punctuation">&quot;</span></span> <span class="token attr-name">slot-scope</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>scope<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        创建时间：{{scope.row['createDate'] | date_timeline('YYYY-MM-DD HH:mm:ss')}}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">/&gt;</span></span>
        更新时间：{{scope.row['updateDate'] | date_timeline('YYYY-MM-DD HH:mm:ss')}}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>template</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>d2-crud-x</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><h2 id="search表单组件slot自定义"><a href="#search表单组件slot自定义" class="header-anchor">#</a> search表单组件slot自定义</h2> <p>与form表单类似，slot名称为 <code>column.key+'SearchSlot'</code></p> <h2 id="表单helper的slot自定义"><a href="#表单helper的slot自定义" class="header-anchor">#</a> 表单helper的slot自定义</h2> <p>与form表单类似，slot名称为 <code>column.key+'HelperSlot'</code></p> <h2 id="slot快捷字段类型"><a href="#slot快捷字段类型" class="header-anchor">#</a> slot快捷字段类型</h2> <ul><li>type = slot           // 开启该字段行和表单的slot</li> <li>type = slot-all       // 开启该字段所有的slot</li> <li>type = slot-form      // 仅开启该字段表单的slot</li></ul> <p><a href="./types-code">字段类型配置参考</a></p> <h2 id="演示示例"><a href="#演示示例" class="header-anchor">#</a> 演示示例</h2> <p><a href="http://qiniu.veryreader.com/D2CrudPlusExample/index.html#/demo/form/slot" target="_blank" rel="noopener noreferrer">http://qiniu.veryreader.com/D2CrudPlusExample/index.html#/demo/form/slot<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/greper/d2-crud-plus/edit/master//docs/guide/slot.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页</a> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2020-7-13 11:58:27 AM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/d2-crud-plus/guide/types.html" class="prev">
        字段类型列表
      </a></span> <span class="next"><a href="/d2-crud-plus/guide/extends.html">
        自定义扩展
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/d2-crud-plus/assets/js/app.9c9ff646.js" defer></script><script src="/d2-crud-plus/assets/js/2.9f3ba775.js" defer></script><script src="/d2-crud-plus/assets/js/66.b3a44945.js" defer></script>
  </body>
</html>
